/*
 * marketsim-eclipsetrader
 *
 * Copyright (C) 2008-2011 Steve Phelps and John Cartlidge
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 */
package victria.marketsim.core;

import java.io.Serializable;
import java.util.Date;

public class Transaction implements Serializable {

	protected Order bid;
	
	protected Order ask;
		
	protected Date time;
	
	protected int fulfilledQuantity;
	
	protected float transactionPrice;
	
	public Transaction() {
		time = new Date();
	}
	
	public Transaction(Order bid, Order ask, int fulfilledQuantity, 
							float transactionPrice) {
		this();
		this.bid = bid;
		this.ask = ask;
		this.fulfilledQuantity = fulfilledQuantity;
		this.transactionPrice = transactionPrice;
	}

	public Order getAsk() {
		return ask;
	}

	public void setAsk(Order ask) {
		this.ask = ask;
	}

	public Order getBid() {
		return bid;
	}

	public void setBid(Order bid) {
		this.bid = bid;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public float getTransactionPrice() {
		return transactionPrice;
	}

	public void setTransactionPrice(float transactionPrice) {
		this.transactionPrice = transactionPrice;
	}
	
	public String toString() {
		return "(" + getClass() + " bid:" + bid + " ask:" + ask
				+ " fulfilledQuantity:" + fulfilledQuantity 
				+ " transactionPrice:" + transactionPrice + " time:" + time
				+ ")";
	}
	
	public String toPrettyString() {
		return "[" + bid.getTrader() + " with " + ask.getTrader() + " "
				+ transactionPrice + "/" + fulfilledQuantity + "]";
	}
	
}
